package com.wjx.shoolnews.controller;
import com.wjx.shoolnews.pojo.CommonResult;
import com.wjx.shoolnews.pojo.OrdinaryUser;
import com.wjx.shoolnews.service.OrdinaryUserImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;



@RestController
public class OrdinaryUserController {
     @Autowired
     OrdinaryUserImpl ordinaryUserimpl;
    @ResponseBody  // 把返回的结果给浏览器

    @PostMapping("/user/login")
    @CrossOrigin
    public CommonResult OrdinaryUserlogin(@RequestBody OrdinaryUser user){
        String zhanghao=user.getZhanghao().trim();
        String password=user.getPassword().trim();
        return ordinaryUserimpl.getOrdinaryUser(zhanghao,password);
    }

    @ResponseBody  // 把返回的结果给浏览器
    @PostMapping("/user/login/register")
    public CommonResult register(@RequestBody OrdinaryUser user){
//        OrdinaryUser ordinaryUser = new OrdinaryUser();


//        ordinaryUser.setZhanghao(zhanghao.trim());
//        ordinaryUser.setPassword(password.trim());
//        ordinaryUser.setNickname(nickname.trim());


        return ordinaryUserimpl.register(user);
    }


}
